import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDEquipmentLevel {
	/**ID，id =level*10+color*/
	id,
	/**装备等级*/
	level,
	/**品质*/
	color,
	/**属性加成值（百分比）*/
	addCoef,
	/**洗练消耗道具*/
	recastCostItem,
	/**洗练消耗*/
	recastCostNum,
	/**转化消耗道具*/
	changeCostItem,
	/**转化消耗*/
	changeCostNum,
	/**熔炼道具*/
	smeltItem,
	/**熔炼数量*/
	smeltNum,
	/**基础属性系数*/
	baseMathCoef,
	/**强化消耗系数*/
	strengthenCostCoef,
	/**最大强化等级*/
	maxStrengthenLevel,
	/**重铸消耗道具*/
	reforgeCostItem,
	/**重铸消耗*/
	reforgeCostNum,

	/**枚举数量*/
	EnumCount
}



export class CDEquipmentLevel{
	/**ID，id =level*10+color*/
	public id: number;
	/**装备等级*/
	public level: number;
	/**品质*/
	public color: number;
	/**属性加成值（百分比）*/
	public addCoef: number;
	/**洗练消耗道具*/
	public recastCostItem: number;
	/**洗练消耗*/
	public recastCostNum: number;
	/**转化消耗道具*/
	public changeCostItem: number;
	/**转化消耗*/
	public changeCostNum: number;
	/**熔炼道具*/
	public smeltItem: number;
	/**熔炼数量*/
	public smeltNum: number;
	/**基础属性系数*/
	public baseMathCoef: number;
	/**强化消耗系数*/
	public strengthenCostCoef: number;
	/**最大强化等级*/
	public maxStrengthenLevel: number;
	/**重铸消耗道具*/
	public reforgeCostItem: number;
	/**重铸消耗*/
	public reforgeCostNum: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDEquipmentLevel.id: return this.id;
			case E_CDEquipmentLevel.level: return this.level;
			case E_CDEquipmentLevel.color: return this.color;
			case E_CDEquipmentLevel.addCoef: return this.addCoef;
			case E_CDEquipmentLevel.recastCostItem: return this.recastCostItem;
			case E_CDEquipmentLevel.recastCostNum: return this.recastCostNum;
			case E_CDEquipmentLevel.changeCostItem: return this.changeCostItem;
			case E_CDEquipmentLevel.changeCostNum: return this.changeCostNum;
			case E_CDEquipmentLevel.smeltItem: return this.smeltItem;
			case E_CDEquipmentLevel.smeltNum: return this.smeltNum;
			case E_CDEquipmentLevel.baseMathCoef: return this.baseMathCoef;
			case E_CDEquipmentLevel.strengthenCostCoef: return this.strengthenCostCoef;
			case E_CDEquipmentLevel.maxStrengthenLevel: return this.maxStrengthenLevel;
			case E_CDEquipmentLevel.reforgeCostItem: return this.reforgeCostItem;
			case E_CDEquipmentLevel.reforgeCostNum: return this.reforgeCostNum;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDEquipmentLevel.id: this.id = v; break;
			case E_CDEquipmentLevel.level: this.level = v; break;
			case E_CDEquipmentLevel.color: this.color = v; break;
			case E_CDEquipmentLevel.addCoef: this.addCoef = v; break;
			case E_CDEquipmentLevel.recastCostItem: this.recastCostItem = v; break;
			case E_CDEquipmentLevel.recastCostNum: this.recastCostNum = v; break;
			case E_CDEquipmentLevel.changeCostItem: this.changeCostItem = v; break;
			case E_CDEquipmentLevel.changeCostNum: this.changeCostNum = v; break;
			case E_CDEquipmentLevel.smeltItem: this.smeltItem = v; break;
			case E_CDEquipmentLevel.smeltNum: this.smeltNum = v; break;
			case E_CDEquipmentLevel.baseMathCoef: this.baseMathCoef = v; break;
			case E_CDEquipmentLevel.strengthenCostCoef: this.strengthenCostCoef = v; break;
			case E_CDEquipmentLevel.maxStrengthenLevel: this.maxStrengthenLevel = v; break;
			case E_CDEquipmentLevel.reforgeCostItem: this.reforgeCostItem = v; break;
			case E_CDEquipmentLevel.reforgeCostNum: this.reforgeCostNum = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDEquipmentLevel> = new HashMap<number, CDEquipmentLevel>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDEquipmentLevel[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDEquipmentLevel();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].level = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].color = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].addCoef = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].recastCostItem = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].recastCostNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].changeCostItem = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].changeCostNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].smeltItem = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].smeltNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].baseMathCoef = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].strengthenCostCoef = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].maxStrengthenLevel = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reforgeCostItem = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reforgeCostNum = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDEquipmentLevel{
		return this.datas ? this.datas.get(id) : null;
	}
}
